import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-10-03
 * Time:22:54
 */
public class Test {
    public static void main(String[] args) {
        CardDemo cardDemo = new CardDemo();
        //1.买 52张牌
        System.out.println("洗牌前：");
        List<Card> cardList = cardDemo.buyCard();
        System.out.println(cardList);
        //2.洗牌
        System.out.println("洗牌后：");
        cardDemo.shuffle(cardList);
        System.out.println(cardList);
        //3.3个人 每个人轮流揭5张牌
        System.out.println("抽牌：");
        List<List<Card>> ret = cardDemo.play(cardList);

        for (int i = 0; i < ret.size(); i++) {
            System.out.println("第"+(1+i)+"个人的牌："+ret.get(i));
        }
        System.out.println("剩下的牌：");
        System.out.println(cardList);
    }
    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list0 = new ArrayList<>();
        //处理第一行
        list0.add(1);
        ret.add(list0);

        //从第2行开始 进行求每个元素
        for (int i = 1; i < numRows; i++) {
            //处理第一个元素
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);
            //中间
            //第一个元素已经处理，从第二个元素开始进行
            List<Integer> preRow = ret.get(i-1);//前一行
            for (int j = 1; j < i; j++) {
                int val1 = preRow.get(j);
                int val2 = preRow.get(j-1);
                curRow.add(val1+val2);
            }
            //尾巴
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
    public static void main3(String[] args) {
        List<List<Integer>> list = new ArrayList<>();
        List<List<Integer>> ret = generate(4);
        for (int i = 0; i < ret.size(); i++) {
            for (int j = 0; j < ret.get(i).size(); j++) {
                System.out.print(ret.get(i).get(j) + " ");
            }
            System.out.println();
        }
        //System.out.println(list1);
    }
    public static void main2(String[] args) {
        List<List<Integer>> list = new ArrayList<>();
        List<Integer> list1 = new ArrayList<>();
        list1.add(1);
        list1.add(2);
        list.add(list1);

        List<Integer> list2 = new ArrayList<>();
        list2.add(11);
        list2.add(21);
        list.add(list2);

        System.out.println(list);//[[1, 2], [11, 21]]
    }
    public static void main1(String[] args) {
        //杨辉三角
        List<List<Integer>> list = new ArrayList<>();
        list.add(new ArrayList<>());
        list.add(new ArrayList<>());
        System.out.println(list);//[[], []]

        //list.add(new ArrayList<>(5));//想要添加二维数组元素不可以这个添加，这个的意思是给5个内存空间
    }
}
